home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume6 / glib / part07 < prev    next >
Encoding:
Text File  |  1989-05-14  |  42.6 KB  |  2,006 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v06i108: glib part 7 of 15
  4. Reply-To: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  5.  
  6. Posting-number: Volume 6, Issue 108
  7. Submitted-by: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  8. Archive-name: glib/part07
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 7 (of 15)."
  17. # Contents:  amigmach.c d10urp.mnu menutoc.l
  18. # Wrapped by lee@uhccux on Sun May  7 00:40:14 1989
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'amigmach.c' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'amigmach.c'\"
  22. else
  23. echo shar: Extracting \"'amigmach.c'\" \(13113 characters\)
  24. sed "s/^X//" >'amigmach.c' <<'END_OF_FILE'
  25. X/* $Id: amigmach.c,v 1.6 89/05/06 17:13:10 lee Exp $
  26. X *
  27. X * GLIB - a Generic LIBrarian and editor for synths
  28. X *
  29. X * Machine dependent stuff.
  30. X *
  31. X * Amiga version.
  32. X * Alan Bland
  33. X *
  34. X * modifications by Mark Rinfret and Dave Weiler
  35. X * $Log:    amigmach.c,v $
  36. X * Revision 1.6  89/05/06  17:13:10  lee
  37. X * rel. to comp.sources.misc
  38. X * 
  39. X */
  40. X
  41. X#include "glib.h"
  42. X#include <stdio.h>
  43. X#include <ctype.h>
  44. X
  45. X#ifndef AZTEC_C
  46. X#include <dos.h>
  47. X#endif
  48. X#include <intuition/intuition.h>
  49. X#include <exec/types.h>
  50. X#include <exec/ports.h>
  51. X#include <exec/io.h>
  52. X#include <exec/devices.h>
  53. X#include <exec/memory.h>
  54. X#include <devices/serial.h>
  55. X
  56. X#ifdef ARP
  57. X    #include <libraries/arpbase.h>
  58. X    #include <arpfunctions.h>
  59. X#endif
  60. X
  61. X#ifdef AZTEC_C
  62. X#include <libraries/dos.h>
  63. X#include <libraries/dosextens.h>
  64. X#include <functions.h>
  65. X#else
  66. X#include <proto/exec.h>
  67. X#include <proto/intuition.h>
  68. X#endif
  69. X
  70. X#ifdef ARP
  71. X    char FileName[FCHARS+1];
  72. X    char DirName[DSIZE+1];
  73. X    struct FileRequester MyFileRequest =
  74. X        {
  75. X        "GLIB file name -->",
  76. X        FileName,
  77. X        DirName,
  78. X        0,
  79. X        0,0,
  80. X        0,
  81. X        0
  82. X        };
  83. X    int FileRequestImminent;
  84. X#else
  85. X    struct IntuitionBase *IntuitionBase;
  86. X    struct GfxBase *GfxBase;
  87. X#endif
  88. X
  89. Xstruct Screen *S;
  90. Xstruct Window *W;
  91. Xstruct RastPort *R;
  92. X
  93. Xint Rows, Cols;
  94. X
  95. X#define TOPEDGE 8    /* how much of screen bar to show */
  96. Xint WindowWidth = 640;
  97. Xint WindowHeight = 200 - TOPEDGE;
  98. X
  99. X/* standard WB colors */
  100. X#define BLUE 0
  101. X#define WHITE 1
  102. X#define BLACK 2
  103. X#define ORANGE 3
  104. X
  105. X
  106. Xhello()
  107. X{
  108. X    windinit();
  109. X    openmidi();
  110. X}
  111. X
  112. Xbye()
  113. X{
  114. X    closemidi();
  115. X    windexit(0);
  116. X}
  117. X
  118. Xint MouseX, MouseY, MouseButtons;
  119. Xint Mouseok = 0;
  120. X
  121. X/* getmouse - get current row and column of mouse */
  122. Xgetmouse(amr,amc)
  123. Xint *amr;
  124. Xint *amc;
  125. X{
  126. X    *amr = MouseY / 8;
  127. X    *amc = MouseX / 8;
  128. X}
  129. X
  130. X/* statmouse - return mouse button state (0=nothing pressed,1=left,2=right) */
  131. Xstatmouse()
  132. X{
  133. X    nextevent(MOUSEBUTTONS, 0);
  134. X    return MouseButtons;
  135. X}
  136. X
  137. X/* Return when either a console key or mouse button is pressed. */
  138. Xmouseorkey()
  139. X{
  140. X    return nextevent(MOUSEBUTTONS | VANILLAKEY, 1);
  141. X}
  142. X
  143. Xflushconsole()
  144. X{
  145. X    while (nextevent(VANILLAKEY, 0) >= 0) ;
  146. X}
  147. X
  148. Xgetconsole()
  149. X{
  150. X    return nextevent(VANILLAKEY, 1);
  151. X}
  152. X
  153. Xcursor(state)
  154. Xint state;
  155. X{
  156. X    int x, y;
  157. X    x = R->cp_x;
  158. X    y = R->cp_y - R->Font->tf_Baseline;
  159. X    SetDrMd(R, COMPLEMENT);
  160. X    RectFill(R, x, y, x+8, y+R->Font->tf_YSize-1);
  161. X    SetDrMd(R, JAM2);
  162. X}
  163. X
  164. Xnextevent(flags, wait)
  165. Xlong flags;
  166. Xint wait;
  167. X{
  168. X    register int class, code;
  169. X    register struct IntuiMessage *message;
  170. X    int result;
  171. X
  172. X    cursor(1);
  173. X    ModifyIDCMP(W, CLOSEWINDOW | flags);
  174. X    while (1)
  175. X    {
  176. X        if (wait)
  177. X        {
  178. X            /* get next event, waiting if none are available */
  179. X            while ((message = (struct IntuiMessage *)GetMsg(W->UserPort)) == NULL)
  180. X            {
  181. X            Wait(1<<W->UserPort->mp_SigBit);
  182. X            }
  183. X        }
  184. X        else
  185. X        {
  186. X            /* get next event, but return if none are available */
  187. X            message = (struct IntuiMessage *)GetMsg(W->UserPort);
  188. X            if (message == NULL)
  189. X            {
  190. X            result = -1;
  191. X            break;
  192. X            }
  193. X        }
  194. X        class = message->Class;
  195. X        code = message->Code;
  196. X        MouseX = message->MouseX;
  197. X        MouseY = message->MouseY;
  198. X        ReplyMsg((struct Message *)message);
  199. X
  200. X        switch (class)
  201. X        {
  202. X        case VANILLAKEY:
  203. X            result = code;
  204. X            break;
  205. X        case CLOSEWINDOW:
  206. X            result = 'q';
  207. X            break;
  208. X        case MOUSEBUTTONS:
  209. X            switch (code)
  210. X            {
  211. X            case SELECTDOWN:
  212. X                MouseButtons = 1;
  213. X                break;
  214. X            case MENUDOWN:
  215. X                MouseButtons = 2;
  216. X                break;
  217. X            default:
  218. X                MouseButtons = 0;
  219. X                break;
  220. X            }
  221. X            result = MOUSE;
  222. X            break;
  223. X        default:
  224. X            continue;
  225. X        }
  226. X        break;
  227. X    }
  228. X    cursor(0);
  229. X    return result;
  230. X}
  231. X
  232. X/*------------------------------------------------------------------------
  233. X * MIDI I/O Routines for Amiga.
  234. X *
  235. X * Uses low-level serial I/O for simultaneous reads and writes.
  236. X */
  237. X
  238. Xstruct MsgPort    *MidiInPort, *MidiOutPort;
  239. Xstruct IOExtSer    *MidiIn, *MidiOut;
  240. Xint    SerOpen = 0;
  241. X
  242. Xunsigned char   MidiInBuf;
  243. Xint    MidiDataAvail = 0;
  244. X
  245. X/*
  246. X * start an asynchronous read request from MIDI IN
  247. X */
  248. X
  249. Xstartmidiread()
  250. X{
  251. X    MidiIn->IOSer.io_Data = (APTR) &MidiInBuf;
  252. X    MidiIn->IOSer.io_Length = 1;
  253. X    MidiIn->IOSer.io_Command = CMD_READ;
  254. X    MidiIn->IOSer.io_Flags = IOF_QUICK;    /* use quick I/O */
  255. X    BeginIO((struct IORequest *) MidiIn);
  256. X    /* did I/O complete quickly? */
  257. X    if ((MidiIn->IOSer.io_Flags & IOF_QUICK)) {
  258. X        /* wow, data's coming in fast! */
  259. X        MidiDataAvail = 1;
  260. X    } else {
  261. X        /* no data this time, it'll arrive later */
  262. X        MidiDataAvail = 0;
  263. X    }
  264. X}
  265. X
  266. X/*
  267. X * get a byte from MIDI IN.
  268. X * assumes startmidiread has been previously done.  if statmidi has been
  269. X * checked, this function will not wait.  otherwise, it will wait for
  270. X * a single byte to arrive if none is available.
  271. X */
  272. Xunsigned
  273. Xgetmidi()
  274. X{
  275. X    register struct Message    *io;
  276. X        unsigned result;
  277. X
  278. X    /* return previously-received data, if available */
  279. X    if (MidiDataAvail) {
  280. X                result = MidiInBuf & 0xff;
  281. X        /* start a new I/O */
  282. X        startmidiread();
  283. X        return result;
  284. X    }
  285. X
  286. X    /* read next available byte */
  287. X    io = (struct Message *) CheckIO((struct IORequest *) MidiIn);
  288. X    if (io == FALSE) {
  289. X        /* wait for next byte */
  290. X        WaitIO((struct IORequest *) MidiIn);
  291. X        io = &MidiIn->IOSer.io_Message;
  292. X    }
  293. X
  294. X    Remove(&io->mn_Node);
  295. X    result = MidiInBuf;
  296. X    startmidiread();    /* start I/O for next byte */
  297. X    return result;
  298. X}
  299. X
  300. X/*
  301. X * write one byte to MIDI OUT
  302. X */
  303. X
  304. Xsendmidi(c)
  305. Xint c;
  306. X{
  307. X    char    buf = c;
  308. X#ifdef STATISTICS
  309. X        long    bytesOut;
  310. X        long    start, totalTime, average;
  311. X
  312. X
  313. X        ++bytesOut;
  314. X        start = milliclock();
  315. X#endif
  316. X    MidiOut->IOSer.io_Data = (APTR) &buf;
  317. X    MidiOut->IOSer.io_Length = 1;
  318. X    MidiOut->IOSer.io_Command = CMD_WRITE;
  319. X    DoIO((struct IORequest *) MidiOut);    /* synchronous request */
  320. X#ifdef STATISTICS
  321. X        totalTime += milliclock() - start;
  322. X        average = totalTime / bytesOut;
  323. X#endif
  324. X}
  325. X
  326. X/*  FUNCTION
  327. X        sendmulti - send multiple bytes to midi device
  328. X
  329. X    SYNOPSIS
  330. X        void sendmulti(buffer, count)
  331. X                char    *buffer;
  332. X                int     count;
  333. X
  334. X    DESCRIPTION
  335. X        sendmulti transfers <count> bytes from <buffer> to the currently
  336. X        open midi device.
  337. X
  338. X*/
  339. X
  340. Xvoid
  341. Xsendmulti(buffer, count)
  342. X    char *buffer; int count;
  343. X{
  344. X#ifdef STATISTICS
  345. X        long    bytesOut;
  346. X        long    start, totalTime, average;
  347. X
  348. X
  349. X        bytesOut += count;
  350. X        start = milliclock();
  351. X#endif
  352. X        MidiOut->IOSer.io_Data = (APTR) buffer;
  353. X        MidiOut->IOSer.io_Length = count;
  354. X        MidiOut->IOSer.io_Command = CMD_WRITE;
  355. X        DoIO((struct IORequest *) MidiOut);     /* synchronous request */
  356. X#ifdef STATISTICS
  357. X        totalTime += milliclock() - start;
  358. X        average = totalTime / bytesOut;
  359. X#endif
  360. X
  361. X
  362. X}
  363. X
  364. X/*
  365. X * check if any midi data is waiting to be received
  366. X */
  367. Xstatmidi()
  368. X{
  369. X    /* check if data has previously been received */
  370. X    if (MidiDataAvail) return 1;
  371. X
  372. X    /* check if i/o has completed */
  373. X    return (CheckIO((struct IORequest *) MidiIn) == FALSE) ? 0 : 1;
  374. X}
  375. X
  376. Xopenmidi()
  377. X{
  378. X    /* create message port for serial device */
  379. X        MidiInPort = (struct MsgPort *) CreatePort(SERIALNAME,0L);
  380. X    if (MidiInPort == NULL) fatal("Can't create MidiInPort");
  381. X
  382. X    /* create i/o request block for serial device */
  383. X    MidiIn = (struct IOExtSer *)
  384. X                CreateExtIO(MidiInPort, (long) sizeof(struct IOExtSer));
  385. X    if (MidiIn == NULL) fatal("Can't create MidiIn");
  386. X
  387. X    /* open the serial device */
  388. X    MidiIn->io_SerFlags = SERF_SHARED;
  389. X    SerOpen = OpenDevice(SERIALNAME,0,(struct IORequest *) MidiIn,0) == 0 ? 1 : 0;
  390. X    if (SerOpen == 0) fatal("Can't open serial.device");
  391. X
  392. X    /* set serial device parameters */
  393. X    MidiIn->io_Baud = 31250;
  394. X        MidiIn->io_RBufLen = 512;       /* large input buffer - if your synth
  395. X                     * sends dumps larger than this you
  396. X                     * will have to increase it. */
  397. X    MidiIn->io_SerFlags = SERF_RAD_BOOGIE;
  398. X    MidiIn->IOSer.io_Command = SDCMD_SETPARAMS;
  399. X    DoIO((struct IORequest *) MidiIn);
  400. X
  401. X    /* clone MidiIn into MidiOut to allow simultaneous i/o */
  402. X        MidiOutPort = (struct MsgPort *) CreatePort("MidiOut",0L);
  403. X    if (MidiOutPort == NULL) fatal("Can't create MidiOutPort");
  404. X
  405. X    MidiOut = (struct IOExtSer *)
  406. X            CreateExtIO(MidiOutPort, sizeof(struct IOExtSer));
  407. X    *MidiOut = *MidiIn;
  408. X    MidiOut->IOSer.io_Message.mn_ReplyPort = MidiOutPort;
  409. X
  410. X    /* get the MIDI IN port started */
  411. X    startmidiread();
  412. X}
  413. X
  414. Xclosemidi()
  415. X{
  416. X    if (SerOpen) CloseDevice((struct IORequest *)MidiIn);
  417. X    if (MidiIn) DeleteExtIO((struct IORequest *)MidiIn);
  418. X    if (MidiOut) DeleteExtIO((struct IORequest *)MidiOut);
  419. X    if (MidiInPort) DeletePort(MidiInPort);
  420. X    if (MidiOutPort) DeletePort(MidiOutPort);
  421. X}
  422. X
  423. Xflushmidi()
  424. X{
  425. X    while ( STATMIDI )
  426. X        getmidi();
  427. X}
  428. X
  429. X#ifdef AZTEC_C
  430. Xlong milliclock()
  431. X{
  432. X    static long secs, startSecs, micros, startMicros;
  433. X    long product;
  434. X
  435. X    CurrentTime(&secs, µs);
  436. X    if (startSecs == 0) {
  437. X        startSecs = secs;
  438. X        startMicros = micros;
  439. X    }
  440. X    product =  ((secs - startSecs) * 1000L +
  441. X                (micros - startMicros)/1000L);
  442. X    return product;
  443. X}
  444. X#else
  445. Xlong milliclock()
  446. X{
  447. X    unsigned int clock[2];
  448. X    long milli;
  449. X    timer(clock);
  450. X    milli = clock[0] * 1000 + clock[1] / 1000;
  451. X    return milli;
  452. X}
  453. X#endif
  454. X
  455. Xmillisleep(n)
  456. X{
  457. X    long ticks = n/20;
  458. X
  459. X    if (ticks) Delay(ticks);        /* Avoid the Delay(0) bug! */
  460. X}
  461. X
  462. Xchar *
  463. Xalloc(n)
  464. X{
  465. X    char *p;
  466. X
  467. X    if ( (p=malloc((unsigned)n)) == (char *)NULL ) {
  468. X        fatal("GLIB is out of memory!");
  469. X    }
  470. X    return(p);
  471. X}
  472. X
  473. Xstruct TextAttr font =
  474. X{
  475. X    "topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT
  476. X};
  477. X
  478. Xstruct NewScreen ns =
  479. X{
  480. X    0,0,640,200,2,BLACK,WHITE,HIRES,CUSTOMSCREEN,&font,"",NULL,NULL
  481. X};
  482. X
  483. Xwindinit()
  484. X{
  485. X    struct NewWindow nw;
  486. X
  487. X    if (S != NULL) return;
  488. X
  489. X#ifdef ARP
  490. X    FileRequestImminent = FALSE;
  491. X    /* libraries opened by arpc.o */
  492. X#else
  493. X    IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
  494. X    GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0);
  495. X    if (IntuitionBase == NULL || GfxBase == NULL) exit(1);
  496. X#endif
  497. X
  498. X    if ((S = (struct Screen *) OpenScreen(&ns)) == NULL) exit(1);
  499. X
  500. X    nw.LeftEdge = 0;
  501. X    nw.TopEdge = TOPEDGE;
  502. X    nw.Width = WindowWidth;
  503. X    nw.Height = WindowHeight;
  504. X    nw.DetailPen = BLACK;
  505. X    nw.BlockPen = WHITE;
  506. X    nw.Title = NULL;
  507. X    nw.Flags = SMART_REFRESH | ACTIVATE | BACKDROP |
  508. X           BORDERLESS | NOCAREREFRESH | RMBTRAP;
  509. X    nw.IDCMPFlags = CLOSEWINDOW | VANILLAKEY;
  510. X    nw.Type = CUSTOMSCREEN;
  511. X    nw.FirstGadget = NULL;
  512. X    nw.CheckMark = NULL;
  513. X    nw.Screen = S;
  514. X    nw.BitMap = NULL;
  515. X    if ((W = (struct Window *) OpenWindow(&nw)) == NULL) exit(1);
  516. X    R = W->RPort;
  517. X    SetAPen(R, ORANGE);
  518. X    SetBPen(R, BLACK);
  519. X    ShowTitle(S, FALSE);
  520. X    Cols=80;
  521. X    Rows=24;
  522. X#ifdef ARP
  523. X    MyFileRequest.fr_Window = W;
  524. X#endif
  525. X}
  526. X
  527. Xwindgoto(r,c)
  528. Xint r,c;
  529. X{
  530. X    Move(R, c*8, r*8 + R->Font->tf_Baseline);
  531. X}
  532. X
  533. Xwindeeol()
  534. X{
  535. X    int x, y;
  536. X    x = R->cp_x;
  537. X    y = R->cp_y  - R->Font->tf_Baseline;
  538. X    SetAPen(R, BLACK);
  539. X    RectFill(R, x, y, WindowWidth, y+R->Font->tf_YSize-1);
  540. X    SetAPen(R, ORANGE);
  541. X}
  542. X
  543. Xwinderaserow(r)
  544. X{
  545. X    windgoto(r,0);
  546. X    windeeol();
  547. X}
  548. X
  549. Xwindexit(r)
  550. Xint r;
  551. X{
  552. X#ifdef ARP
  553. X    if (W) CloseWindowSafely(W,NULL);
  554. X#else
  555. X    if (W) CloseWindow(W);
  556. X#endif
  557. X    if (S) CloseScreen(S);
  558. X    exit(r);
  559. X}
  560. X
  561. Xwindclear()
  562. X{
  563. X    SetAPen(R, BLACK);
  564. X    RectFill(R, 0, 0, WindowWidth, WindowHeight);
  565. X    SetAPen(R, ORANGE);
  566. X}
  567. X
  568. X/* windgets - get a line of input from the console, handling backspaces */
  569. Xwindgets(s)
  570. Xchar *s;
  571. X{
  572. X    char *origs = s;
  573. X    int c;
  574. X
  575. X#ifdef ARP
  576. X    if (FileRequestImminent) {
  577. X        FileRequestImminent = FALSE;
  578. X        if (FileRequest(&MyFileRequest)==NULL) {
  579. X                  message("No file name entered");
  580. X            strcpy(s,"");
  581. X              }   
  582. X        else {
  583. X            strcpy(s,DirName);
  584. X            if(s[0]!=0 && (s[strlen(s)-1]!=':'))
  585. X                strcat(s,"/");
  586. X            strcat(s,FileName);
  587. X        }
  588. X    }
  589. X    else {
  590. X#endif
  591. X    SetAPen(R, WHITE);
  592. X
  593. X    while ( (c=getconsole()) != '\n' && c!='\r' && c!= EOF ) {
  594. X        if ( c == '\b' ) {
  595. X            if ( s > origs ) {
  596. X                wbackspace();
  597. X                s--;
  598. X            }
  599. X        }
  600. X        else if (c == 24) {
  601. X            while (s > origs) {
  602. X                wbackspace();
  603. X                s--;
  604. X            }
  605. X        } else if (isprint(c)) {
  606. X            windputc(c);
  607. X            *s++ = c;
  608. X        }
  609. X        windrefresh();
  610. X    }
  611. X    *s = '\0';
  612. X    SetAPen(R, ORANGE);
  613. X#ifdef ARP
  614. X    }
  615. X#endif
  616. X}
  617. X
  618. Xwindstr(s)
  619. Xchar *s;
  620. X{
  621. X#ifdef ARP
  622. X    if (!strnicmp(s,"File name",9))
  623. X        FileRequestImminent = TRUE;
  624. X    else
  625. X#endif
  626. X
  627. X        Text(R, s, strlen(s));
  628. X}
  629. X
  630. Xwindputc(c)
  631. Xint c;
  632. X{
  633. X    char s = c;
  634. X    Text(R, &s, 1);
  635. X}
  636. X
  637. Xwbackspace()
  638. X{
  639. X    int x, y;
  640. X    x = R->cp_x;
  641. X    y = R->cp_y;
  642. X    Move(R, x-8, y);
  643. X    windputc(' ');
  644. X    Move(R, x-8, y);
  645. X}
  646. X
  647. Xwindrefresh()
  648. X{
  649. X}
  650. X
  651. Xbeep()
  652. X{
  653. X    DisplayBeep(S);
  654. X}
  655. X
  656. Xwindhigh()
  657. X{
  658. X}
  659. X
  660. Xwindnorm()
  661. X{
  662. X}
  663. X
  664. Xstruct IntuiText fataltext = { 1,0,COMPLEMENT,16,32,NULL,NULL,NULL };
  665. Xstruct IntuiText canceltext = { 1,0,COMPLEMENT,2,2,NULL,"cancel",NULL };
  666. X
  667. Xfatal(text)
  668. Xchar *text;
  669. X{
  670. X    fataltext.IText = text;
  671. X    AutoRequest(W, &fataltext, NULL, &canceltext, 0, 0, 320, 90);
  672. X    bye();
  673. X}
  674. X
  675. X/****************
  676. X * openls(), nextls(), and closels() are used to scan the current directory.
  677. X ***************/
  678. X
  679. X#ifdef AZTEC_C
  680. X#include "amigadir.h"
  681. Xstatic DIR *dir;
  682. Xopenls()
  683. X{
  684. X    dir = opendir("");
  685. X}
  686. Xchar *
  687. Xnextls()
  688. X{
  689. X    struct direct *result;
  690. X
  691. X    if (dir) {
  692. X        if (result = readdir(dir)) {
  693. X            return result->d_name;
  694. X        }
  695. X        closels();
  696. X    }
  697. X    return NULL;
  698. X}
  699. X
  700. Xclosels()
  701. X{
  702. X    if (dir) {
  703. X        closedir(dir);
  704. X        dir = NULL;
  705. X    }
  706. X}
  707. X#else
  708. Xstruct FileInfoBlock *lsinfo = NULL;
  709. X
  710. Xopenls()
  711. X{
  712. X}
  713. X
  714. Xchar *
  715. Xnextls()
  716. X{
  717. X    int error;
  718. X    if (lsinfo == NULL) {
  719. X        lsinfo = (struct FileInfoBlock *) alloc(sizeof(struct FileInfoBlock));
  720. X        error = dfind(lsinfo, "#?", 0);
  721. X    } else {
  722. X        error = dnext(lsinfo);
  723. X    }
  724. X    if (error == 0) {
  725. X        return lsinfo->fib_FileName;
  726. X    } else {
  727. X        return NULL;
  728. X    }
  729. X}
  730. X
  731. Xclosels()
  732. X{
  733. X    free(lsinfo);
  734. X    lsinfo = NULL;
  735. X}
  736. X#endif
  737. X
  738. END_OF_FILE
  739. if test 13113 -ne `wc -c <'amigmach.c'`; then
  740.     echo shar: \"'amigmach.c'\" unpacked with wrong size!
  741. fi
  742. # end of 'amigmach.c'
  743. fi
  744. if test -f 'd10urp.mnu' -a "${1}" != "-c" ; then 
  745.   echo shar: Will not clobber existing file \"'d10urp.mnu'\"
  746. else
  747. echo shar: Extracting \"'d10urp.mnu'\" \(13527 characters\)
  748. sed "s/^X//" >'d10urp.mnu' <<'END_OF_FILE'
  749. X/* $Id: d10urp.mnu,v 1.6 89/05/06 17:13:19 lee Exp $
  750. X * GLIB - a Generic LIBrarian and editor for synths
  751. X *
  752. X * D10 User Rhythm Pattern Librarian
  753. X *
  754. X * Code started 31 JAN 89 --  Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
  755. X * modified by Greg Lee
  756. X * 
  757. X */
  758. X
  759. X#include "glib.h"
  760. X#include "vis.h"
  761. X
  762. X#define D10URPSIZE 588
  763. X#define URPBASEADDR 0x0a0000
  764. X#define RESERVESIZE 20
  765. X
  766. Xchar *visnum(), *visonoff();
  767. X
  768. X
  769. X/* This array contains arbitrary screen labels */
  770. Xstruct labelinfo Ldurp[] = {
  771. X#MENU
  772. X
  773. X
  774. X
  775. X
  776. X
  777. X
  778. X
  779. X
  780. X
  781. X
  782. X
  783. X
  784. X               No User Rhythm Pattern editing is supported.
  785. X
  786. X
  787. X
  788. X
  789. X
  790. X
  791. X
  792. X
  793. X
  794. X
  795. X Press SPACE BAR to sound note %   at volume %   for duration %  on channel % .
  796. X#END
  797. X-1,-1,NULL
  798. X};
  799. X
  800. Xstruct paraminfo  Pdurp[] =  {
  801. X/*
  802. XNAME        TYPE        POS    MAX    OFFSET    MASK    SHIFT    ADHOC
  803. X */
  804. X#O autopitch    num        %%    127    -60
  805. X#O autovol    num        %%    127    -63
  806. X#O autodur    num        %%    20    -5    *5
  807. X#O autochan    num        %%    16    -1    *5
  808. XNULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
  809. X};
  810. X
  811. X
  812. X/*
  813. X * durpnum
  814. X *
  815. X * Convert a voice number (0 to 31) to the string displayed in the
  816. X * librarian (ie. 51 to 88).
  817. X */
  818. X
  819. Xchar *
  820. Xdurpnum(n)
  821. X{
  822. X    static char v[3];
  823. X
  824. X    if ( n < 0 || n > 31 )
  825. X        return("??");
  826. X
  827. X    v[0] = n/8 + '5';
  828. X    v[1] = n%8 + '1';
  829. X    v[2] = '\0';
  830. X    return(v);
  831. X}
  832. X
  833. X/*
  834. X * dnumurp
  835. X *
  836. X * Convert a display-style voice number (55 to 88) to internal
  837. X * format (0 to 31).
  838. X */
  839. X
  840. Xdnumurp(n)
  841. Xint n;
  842. X{
  843. X    int ld, rd;
  844. X    
  845. X    /* crack out the digits as octal codes */
  846. X    ld = (n / 10) - 1; /* middle digit */
  847. X    rd = (n % 10) - 1; /* right digit */
  848. X
  849. X    if(ld < 4 || ld > 7 || rd < 0 || rd > 7) {
  850. X        return(-1);
  851. X    } else {
  852. X        return(((ld - 4) * 8) + rd); /* combine as octal */
  853. X    }
  854. X}
  855. X
  856. X/*
  857. X * durpdin
  858. X *
  859. X * Take library bank 'data' and stuff values in the P array, by using
  860. X * the setval function.
  861. X */
  862. X
  863. Xdurpdin(data)
  864. Xchar *data;
  865. X{
  866. X    /* The first RESERVESIZE bytes are reserved (arbitrarily) for the voice name */
  867. X}
  868. X
  869. X/*
  870. X * durpdout
  871. X *
  872. X * Take (possibly changed) parameters values out of the P array and
  873. X * put them back into the library bank 'data'.
  874. X */
  875. X
  876. Xdurpdout(data)
  877. Xchar *data;
  878. X{
  879. X}
  880. X
  881. X/*
  882. X * durpsedit
  883. X *
  884. X * Send a single voice to the edit buffer of the D10.  This will be whatever
  885. X * voice is currently selected.
  886. X */
  887. X
  888. Xdurpsedit(data)
  889. Xchar *data;
  890. X{
  891. X}
  892. X
  893. X/*
  894. X * durpnof
  895. X *
  896. X * Return a pointer to the voice name buried in library bank data.
  897. X */
  898. Xchar *
  899. Xdurpnof(data)
  900. Xchar *data;
  901. X{
  902. X    static char buf[10];
  903. X    int n, v;
  904. X
  905. X    for(n = 0; n < D10URPSIZE; n++)
  906. X        if ( data[n + RESERVESIZE] != 0 ) break;
  907. X    if ( n != D10URPSIZE ) {
  908. X        v = data[RESERVESIZE + 2] + (16 * data[RESERVESIZE + 3]);
  909. X        sprintf(buf, "%2d events", v);
  910. X    }
  911. X    else
  912. X        strcpy(buf, "         ");
  913. X    return(buf);
  914. X}
  915. X
  916. X/*
  917. X * durpsnof
  918. X *
  919. X * Set the voice name buried in data to name.
  920. X */
  921. Xdurpsnof(data,name)
  922. Xchar *data;
  923. Xchar *name;
  924. X{
  925. X}
  926. X
  927. X/* durpsone - send a single voice to the D10 */
  928. Xdurpsone(iv, data)
  929. Xint iv;
  930. Xchar *data;
  931. X{
  932. X    int n;
  933. X    int cksum;
  934. X    long curadd;
  935. X    int addbyte;
  936. X
  937. X    curadd = URPBASEADDR;
  938. X
  939. X    for(n = 0; n < iv; n++) {
  940. X        curadd += 0x44c;    /* D10URPSIZE */
  941. X
  942. X        if((curadd & 0x80) != 0) {
  943. X            curadd &= 0x7fff7f;
  944. X            curadd += 0x100;
  945. X        }
  946. X        if((curadd & 0x8000) != 0) {
  947. X            curadd &= 0x7f7f7f;
  948. X            curadd += 0x10000;
  949. X        }
  950. X    }
  951. X
  952. X    sendmidi(0xf0);
  953. X    sendmidi(0x41);
  954. X    sendmidi(0x10);
  955. X    sendmidi(0x16);
  956. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  957. X
  958. X    addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  959. X    sendmidi(addbyte);
  960. X    cksum = addbyte;
  961. X    addbyte = ((curadd >> 8) & 0x7f);
  962. X    sendmidi(addbyte);
  963. X    cksum += addbyte;
  964. X    addbyte = (curadd & 0x7f);        /* address lsb */
  965. X    sendmidi(addbyte);
  966. X    cksum += addbyte;
  967. X
  968. X    for(n = 0; n < 256; n++) {
  969. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  970. X        cksum += data[n + RESERVESIZE] & 0x7f;
  971. X    }
  972. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  973. X    sendmidi(EOX);
  974. X
  975. X    curadd += 256;
  976. X
  977. X    if((curadd & 0x8000) != 0) {
  978. X        curadd &= 0x7f7f7f;
  979. X        curadd += 0x10000;
  980. X    }
  981. X    sendmidi(0xf0);
  982. X    sendmidi(0x41);
  983. X    sendmidi(0x10);
  984. X    sendmidi(0x16);
  985. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  986. X
  987. X    addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  988. X    sendmidi(addbyte);
  989. X    cksum = addbyte;
  990. X    addbyte = ((curadd >> 8) & 0x7f);
  991. X    sendmidi(addbyte);
  992. X    cksum += addbyte;
  993. X    addbyte = (curadd & 0x7f);        /* address lsb */
  994. X    sendmidi(addbyte);
  995. X    cksum += addbyte;
  996. X
  997. X    for(n = 256; n < 512; n++) {
  998. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  999. X        cksum += data[n + RESERVESIZE] & 0x7f;
  1000. X    }
  1001. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  1002. X    sendmidi(EOX);
  1003. X
  1004. X
  1005. X    curadd += 256;
  1006. X
  1007. X    if((curadd & 0x8000) != 0) {
  1008. X        curadd &= 0x7f7f7f;
  1009. X        curadd += 0x10000;
  1010. X    }
  1011. X
  1012. X    sendmidi(0xf0);
  1013. X    sendmidi(0x41);
  1014. X    sendmidi(0x10);
  1015. X    sendmidi(0x16);
  1016. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  1017. X
  1018. X    addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  1019. X    sendmidi(addbyte);
  1020. X    cksum = addbyte;
  1021. X    addbyte = ((curadd >> 8) & 0x7f);
  1022. X    sendmidi(addbyte);
  1023. X    cksum += addbyte;
  1024. X    addbyte = (curadd & 0x7f);        /* address lsb */
  1025. X    sendmidi(addbyte);
  1026. X    cksum += addbyte;
  1027. X
  1028. X    for(n = 512; n < (D10URPSIZE - 512); n++) {
  1029. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  1030. X        cksum += data[n + RESERVESIZE] & 0x7f;
  1031. X    }
  1032. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  1033. X    sendmidi(EOX);
  1034. X
  1035. X    return(0);
  1036. X}
  1037. X
  1038. X/* durpgbulk - Request and read a bulk dump from the D10 */
  1039. Xdurpgbulk(data)
  1040. Xchar *data;
  1041. X{
  1042. X    static    char Buff[BUFSIZ];
  1043. X    int n, v, b2, ret = 1;
  1044. X    long begin, toolong;
  1045. X    long curadd;
  1046. X    int addbyte;
  1047. X    int cksum;
  1048. X    
  1049. X    sprintf(Buff,"\n");
  1050. X    windstr(Buff);
  1051. X    
  1052. X    curadd = URPBASEADDR;
  1053. X
  1054. X    for(v = 0; v < Nvoices; v++) {
  1055. X
  1056. X        flushmidi();
  1057. X
  1058. X        if(v % 10 != 0) {
  1059. X            sprintf(Buff, ".");
  1060. X        } else {
  1061. X            sprintf(Buff,"%d", (v / 10));
  1062. X        }
  1063. X        windstr(Buff);
  1064. X
  1065. X    /* request the voice */
  1066. X        sendmidi(0xf0);
  1067. X        sendmidi(0x41);
  1068. X        sendmidi(0x10);
  1069. X        sendmidi(0x16);
  1070. X        sendmidi(0x11);        /* RQ1 - Data request 1 command */
  1071. X
  1072. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  1073. X        sendmidi(addbyte);
  1074. X        cksum = addbyte;
  1075. X        addbyte = ((curadd >> 8) & 0x7f);
  1076. X        sendmidi(addbyte);
  1077. X        cksum += addbyte;
  1078. X        addbyte = (curadd & 0x7f);        /* address lsb */
  1079. X        sendmidi(addbyte);
  1080. X        cksum += addbyte;
  1081. X
  1082. X        sendmidi(0x00);        /* length msb */
  1083. X        cksum += 0x00;
  1084. X        sendmidi(0x04);        /* should be D10URPSIZE */
  1085. X        cksum += 0x04;
  1086. X        sendmidi(0x4c);        /* length lsb */
  1087. X        cksum += 0x4c;
  1088. X
  1089. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  1090. X        sendmidi(EOX);
  1091. X    
  1092. X    /* set up timeout */
  1093. X        begin = milliclock();
  1094. X        toolong = begin + (1000 * TIMEOUT);
  1095. X
  1096. X    /* read header */
  1097. X        for(n = 0; n < 8; ) {
  1098. X            if ( STATMIDI ) {
  1099. X                b2 = (getmidi() & 0xff);
  1100. X                /* burn active sensing and timing clock */
  1101. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1102. X                    n++;
  1103. X            } else {
  1104. X                if ( milliclock() > toolong ) {
  1105. X                    Reason = "Timeout waiting for header";
  1106. X                    goto getout;
  1107. X                }
  1108. X            }
  1109. X        }
  1110. X
  1111. X    /* read data */
  1112. X        for(n = 0; n < 256; ) {
  1113. X            if ( STATMIDI ) {
  1114. X                b2 = (getmidi() & 0xff);
  1115. X                /* burn active sensing and timing clock */
  1116. X                if((b2 != 0xfe) && (b2 != 0xf8)) {
  1117. X                    VOICEBYTE(data,v,n + RESERVESIZE) = b2;
  1118. X                    n++;
  1119. X                }
  1120. X            } else {
  1121. X                if ( milliclock() > toolong ) {
  1122. X                    Reason = "Timeout reading data";
  1123. X                    goto timeout0;
  1124. X                }
  1125. X            }
  1126. X        }
  1127. X
  1128. X    timeout0:
  1129. X        if ( n != 256 ) {
  1130. X            Reason = "Timeout reading data!";
  1131. X            goto getout;
  1132. X        }
  1133. X
  1134. X    /* read checksum */
  1135. X        for(n = 0; n < 1; ) {
  1136. X            if ( STATMIDI ) {
  1137. X                b2 = (getmidi() & 0xff);
  1138. X                /* burn active sensing and timing clock */
  1139. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1140. X                    n++;
  1141. X            } else {
  1142. X                if ( milliclock() > toolong ) {
  1143. X                    Reason = "Timeout reading checksum";
  1144. X                    goto getout;
  1145. X                }
  1146. X            }
  1147. X        }
  1148. X
  1149. X    /* read EOX */
  1150. X        for(n = 0; n < 1; ) {
  1151. X            if ( STATMIDI ) {
  1152. X                b2 = (getmidi() & 0xff);
  1153. X                /* burn active sensing and timing clock */
  1154. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1155. X                    if ( b2 != EOX ) {
  1156. X                        sprintf(Buff,"EOX not received (%X)\n", b2);
  1157. X                        Reason = Buff;
  1158. X                        goto getout;
  1159. X                    }
  1160. X                    n++;
  1161. X            } else {
  1162. X                if ( milliclock() > toolong ) {
  1163. X                    Reason = "Timeout reading EOX";
  1164. X                    goto getout;
  1165. X                }
  1166. X            }
  1167. X        }
  1168. X
  1169. X    /* read header */
  1170. X        for(n = 0; n < 8; ) {
  1171. X            if ( STATMIDI ) {
  1172. X                b2 = (getmidi() & 0xff);
  1173. X                /* burn active sensing and timing clock */
  1174. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1175. X                    n++;
  1176. X            } else {
  1177. X                if ( milliclock() > toolong ) {
  1178. X                    Reason = "Timeout waiting for header";
  1179. X                    goto getout;
  1180. X                }
  1181. X            }
  1182. X        }
  1183. X
  1184. X    /* read data */
  1185. X        for(n = 0; n < 256; ) {
  1186. X            if ( STATMIDI ) {
  1187. X                b2 = (getmidi() & 0xff);
  1188. X                /* burn active sensing and timing clock */
  1189. X                if((b2 != 0xfe) && (b2 != 0xf8)) {
  1190. X                    VOICEBYTE(data,v,n + RESERVESIZE + 256) = b2;
  1191. X                    n++;
  1192. X                }
  1193. X            } else {
  1194. X                if ( milliclock() > toolong ) {
  1195. X                    Reason = "Timeout reading data";
  1196. X                    goto timeout1;
  1197. X                }
  1198. X            }
  1199. X        }
  1200. X
  1201. X    timeout1:
  1202. X        if ( n != 256 ) {
  1203. X            Reason = "Timeout reading data!";
  1204. X            goto getout;
  1205. X        }
  1206. X
  1207. X    /* read checksum */
  1208. X        for(n = 0; n < 1; ) {
  1209. X            if ( STATMIDI ) {
  1210. X                b2 = (getmidi() & 0xff);
  1211. X                /* burn active sensing and timing clock */
  1212. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1213. X                    n++;
  1214. X            } else {
  1215. X                if ( milliclock() > toolong ) {
  1216. X                    Reason = "Timeout reading checksum";
  1217. X                    goto getout;
  1218. X                }
  1219. X            }
  1220. X        }
  1221. X
  1222. X    /* read EOX */
  1223. X        for(n = 0; n < 1; ) {
  1224. X            if ( STATMIDI ) {
  1225. X                b2 = (getmidi() & 0xff);
  1226. X                /* burn active sensing and timing clock */
  1227. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1228. X                    if ( b2 != EOX ) {
  1229. X                        sprintf(Buff,"EOX not received (%X)\n", b2);
  1230. X                        Reason = Buff;
  1231. X                        goto getout;
  1232. X                    }
  1233. X                    n++;
  1234. X            } else {
  1235. X                if ( milliclock() > toolong ) {
  1236. X                    Reason = "Timeout reading EOX";
  1237. X                    goto getout;
  1238. X                }
  1239. X            }
  1240. X        }
  1241. X
  1242. X    /* read header */
  1243. X        for(n = 0; n < 8; ) {
  1244. X            if ( STATMIDI ) {
  1245. X                b2 = (getmidi() & 0xff);
  1246. X                /* burn active sensing and timing clock */
  1247. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1248. X                    n++;
  1249. X            } else {
  1250. X                if ( milliclock() > toolong ) {
  1251. X                    Reason = "Timeout waiting for header";
  1252. X                    goto getout;
  1253. X                }
  1254. X            }
  1255. X        }
  1256. X
  1257. X    /* read data */
  1258. X        for(n = 0; n < 76; ) {
  1259. X            if ( STATMIDI ) {
  1260. X                b2 = (getmidi() & 0xff);
  1261. X                /* burn active sensing and timing clock */
  1262. X                if((b2 != 0xfe) && (b2 != 0xf8)) {
  1263. X                    VOICEBYTE(data,v,n + RESERVESIZE + 512) = b2;
  1264. X                    n++;
  1265. X                }
  1266. X            } else {
  1267. X                if ( milliclock() > toolong ) {
  1268. X                    Reason = "Timeout reading data";
  1269. X                    goto timeout2;
  1270. X                }
  1271. X            }
  1272. X        }
  1273. X
  1274. X    timeout2:
  1275. X        if ( n != 76 ) {
  1276. X            Reason = "Timeout reading data!";
  1277. X            goto getout;
  1278. X        }
  1279. X
  1280. X    /* read checksum */
  1281. X        for(n = 0; n < 1; ) {
  1282. X            if ( STATMIDI ) {
  1283. X                b2 = (getmidi() & 0xff);
  1284. X                /* burn active sensing and timing clock */
  1285. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1286. X                    n++;
  1287. X            } else {
  1288. X                if ( milliclock() > toolong ) {
  1289. X                    Reason = "Timeout reading checksum";
  1290. X                    goto getout;
  1291. X                }
  1292. X            }
  1293. X        }
  1294. X
  1295. X    /* read EOX */
  1296. X        for(n = 0; n < 1; ) {
  1297. X            if ( STATMIDI ) {
  1298. X                b2 = (getmidi() & 0xff);
  1299. X                /* burn active sensing and timing clock */
  1300. X                if((b2 != 0xfe) && (b2 != 0xf8))
  1301. X                    if ( b2 != EOX ) {
  1302. X                        sprintf(Buff,"EOX not received (%X)\n", b2);
  1303. X                        Reason = Buff;
  1304. X                        goto getout;
  1305. X                    }
  1306. X                    n++;
  1307. X            } else {
  1308. X                if ( milliclock() > toolong ) {
  1309. X                    Reason = "Timeout reading EOX";
  1310. X                    goto getout;
  1311. X                }
  1312. X            }
  1313. X        }
  1314. X
  1315. X        curadd += 0x44c;        /* D10URPSIZE */
  1316. X
  1317. X        if((curadd & 0x80) != 0) {
  1318. X            curadd &= 0x7fff7f;
  1319. X            curadd += 0x100;
  1320. X        }
  1321. X        if((curadd & 0x8000) != 0) {
  1322. X            curadd &= 0x7f7f7f;
  1323. X            curadd += 0x10000;
  1324. X        }
  1325. X
  1326. X    } /* go back for another voice */
  1327. X
  1328. X    Reason = "";
  1329. X    ret = 0;    /* all's well */
  1330. X
  1331. Xgetout:
  1332. X    return(ret);
  1333. X}
  1334. X
  1335. X/* durpsbulk - send a bulk dump to the D10 */
  1336. Xdurpsbulk(data)
  1337. Xchar *data;
  1338. X{
  1339. X    static char Buff[BUFSIZ];
  1340. X    int v, n;
  1341. X    int cksum;
  1342. X    long curadd, intadd;
  1343. X    int addbyte, databyte;
  1344. X    int curoff;
  1345. X
  1346. X    curadd = URPBASEADDR;
  1347. X    curoff = 0;    
  1348. X    sprintf(Buff,"\n");
  1349. X    windstr(Buff);
  1350. X
  1351. X    for(v = 0; v <Nvoices ; v++) {
  1352. X        if((((v > 63) ? (v - 64) : v) % 10) != 0) {
  1353. X            sprintf(Buff, ".");
  1354. X        } else {
  1355. X            sprintf(Buff,"%d", (((v > 63) ? (v - 64) : v) / 10));
  1356. X        }
  1357. X
  1358. X        windstr(Buff);
  1359. X
  1360. X        sendmidi(0xf0);
  1361. X        sendmidi(0x41);
  1362. X        sendmidi(0x10);
  1363. X        sendmidi(0x16);
  1364. X        sendmidi(0x12);        /* DT1 - Data set 1 command */
  1365. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  1366. X        sendmidi(addbyte);
  1367. X        cksum = addbyte;
  1368. X        addbyte = ((curadd >> 8) & 0x7f);
  1369. X        sendmidi(addbyte);
  1370. X        cksum += addbyte;
  1371. X        addbyte = (curadd & 0x7f);        /* address lsb */
  1372. X        sendmidi(addbyte);
  1373. X        cksum += addbyte;
  1374. X
  1375. X        for(n = 0; n < 256; n++) {
  1376. X            databyte = data[curoff + n + RESERVESIZE] & 0x7f;
  1377. X            sendmidi(databyte);
  1378. X            cksum += databyte;
  1379. X        }
  1380. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  1381. X        sendmidi(EOX);
  1382. X
  1383. X        intadd = curadd + 256;
  1384. X
  1385. X        if((intadd & 0x8000) != 0) {
  1386. X            intadd &= 0x7f7f7f;
  1387. X            intadd += 0x10000;
  1388. X        }
  1389. X
  1390. X        sendmidi(0xf0);
  1391. X        sendmidi(0x41);
  1392. X        sendmidi(0x10);
  1393. X        sendmidi(0x16);
  1394. X        sendmidi(0x12);        /* DT1 - Data set 1 command */
  1395. X        addbyte = ((intadd >> 16) & 0x7f);    /* address msb */
  1396. X        sendmidi(addbyte);
  1397. X        cksum = addbyte;
  1398. X        addbyte = ((intadd >> 8) & 0x7f);
  1399. X        sendmidi(addbyte);
  1400. X        cksum += addbyte;
  1401. X        addbyte = (intadd & 0x7f);        /* address lsb */
  1402. X        sendmidi(addbyte);
  1403. X        cksum += addbyte;
  1404. X
  1405. X        for(n = 256; n < 512; n++) {
  1406. X            databyte = data[curoff + n + RESERVESIZE] & 0x7f;
  1407. X            sendmidi(databyte);
  1408. X            cksum += databyte;
  1409. X        }
  1410. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  1411. X        sendmidi(EOX);
  1412. X
  1413. X        intadd += 256;
  1414. X
  1415. X        if((intadd & 0x8000) != 0) {
  1416. X            intadd &= 0x7f7f7f;
  1417. X            intadd += 0x10000;
  1418. X        }
  1419. X
  1420. X        sendmidi(0xf0);
  1421. X        sendmidi(0x41);
  1422. X        sendmidi(0x10);
  1423. X        sendmidi(0x16);
  1424. X        sendmidi(0x12);        /* DT1 - Data set 1 command */
  1425. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  1426. X        sendmidi(addbyte);
  1427. X        cksum = addbyte;
  1428. X        addbyte = ((curadd >> 8) & 0x7f);
  1429. X        sendmidi(addbyte);
  1430. X        cksum += addbyte;
  1431. X        addbyte = (curadd & 0x7f);        /* address lsb */
  1432. X        sendmidi(addbyte);
  1433. X        cksum += addbyte;
  1434. X
  1435. X        for(n = 512; n < (D10URPSIZE - 512); n++) {
  1436. X            databyte = data[curoff + n + RESERVESIZE] & 0x7f;
  1437. X            sendmidi(databyte);
  1438. X            cksum += databyte;
  1439. X        }
  1440. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  1441. X        sendmidi(EOX);
  1442. X
  1443. X        curadd += 0x44c;        /* D10URPSIZE */
  1444. X
  1445. X        if((curadd & 0x80) != 0) {
  1446. X            curadd &= 0x7fff7f;
  1447. X            curadd += 0x100;
  1448. X        }
  1449. X        if((curadd & 0x8000) != 0) {
  1450. X            curadd &= 0x7f7f7f;
  1451. X            curadd += 0x10000;
  1452. X        }
  1453. X        curoff += (D10URPSIZE + RESERVESIZE);
  1454. X    }
  1455. X    return(0);
  1456. X}
  1457. X
  1458. X/* end */
  1459. END_OF_FILE
  1460. if test 13527 -ne `wc -c <'d10urp.mnu'`; then
  1461.     echo shar: \"'d10urp.mnu'\" unpacked with wrong size!
  1462. fi
  1463. # end of 'd10urp.mnu'
  1464. fi
  1465. if test -f 'menutoc.l' -a "${1}" != "-c" ; then 
  1466.   echo shar: Will not clobber existing file \"'menutoc.l'\"
  1467. else
  1468. echo shar: Extracting \"'menutoc.l'\" \(12722 characters\)
  1469. sed "s/^X//" >'menutoc.l' <<'END_OF_FILE'
  1470. X%{
  1471. X/* $Id: menutoc.l,v 1.6 89/05/06 17:13:37 lee Exp $
  1472. X *    menutoc.l    -- Greg Lee, lee@uhccux.uhcc.hawaii.edu
  1473. X *               February 1989
  1474. X * Scott Snyder added cmd line args and fixed a bug (see comment below)
  1475. X * Mark Rinfret made a couple changes for Aztec C
  1476. X * $Log:    menutoc.l,v $
  1477. X * Revision 1.6  89/05/06  17:13:37  lee
  1478. X * rel. to comp.sources.misc
  1479. X * 
  1480. X
  1481. X    Generate C language menu module for Glib from menu specification.
  1482. X
  1483. XCompile:
  1484. X    flex menutoc.l
  1485. X    cc -o menutoc lex.yy.c
  1486. Xor
  1487. X    lex menutoc.l
  1488. X    cc -o menutoc lex.yy.c -ll
  1489. X
  1490. XUsage:
  1491. X    menutoc <file.menu >file.c
  1492. X
  1493. XDescription:
  1494. X
  1495. XMenutoc simplifies constructing and modifying synthesizer-specific
  1496. Xmodules for Tim Thompson's Glib.  It allows the form of the on-screen
  1497. Xmenu to be specified as a picture in the menu source file, and generates
  1498. X'setval' and 'getval' calls automatically.  This version works with
  1499. Xthe version of Glib modified by Michael Kesti.
  1500. X
  1501. X[The original version of flex distributed on Usenet has a bug which
  1502. X prevents setting the start state.  If this is a problem, you can
  1503. X fix it by making two changes to flex's skeleton files:
  1504. X    CHANGE
  1505. X    static int yy_start;
  1506. X    TO
  1507. X    static int yy_start = 0;
  1508. X
  1509. X    CHANGE
  1510. X        yy_start = 1;
  1511. X    TO
  1512. X        if (!yy_start) yy_start = 1;
  1513. X]
  1514. X
  1515. XThe following characterization of how menutoc works is probably
  1516. Xnot entirely clear.  Look at the example k1single.menu and the
  1517. Xsource code to get a more exact idea.  The source k1single.menu
  1518. Xgives the C file k1single.c after processing by menutoc.
  1519. X
  1520. XThe menu source file should contain five special preprocessor
  1521. Xdirectives: '#MENU' (once), '#END' (once), '#O' (one for each
  1522. Xlabel name), '#GETVAL' (once), and '#SETVAL' (once).  The source
  1523. Xfile has four sections:
  1524. X    (1) the portion before the '#MENU' directive is passed
  1525. X        through unchanged to the output,
  1526. X    (2) a picture of the screen menu is given between the
  1527. X        '#MENU' and '#END' directives,
  1528. X    (3) after the '#END' directive is C code with '#O' directives
  1529. X        which specify the data offsets of variables and with
  1530. X        '%%' or '@@' references to the screen locations for
  1531. X        variable values, and
  1532. X    (4) more C code containing somewhere the '#SETVAL' and
  1533. X        '#GETVAL' directives which cause a series of calls
  1534. X        to the 'setval' and 'getval' functions to be generated,
  1535. X        making use of the offset information given by the '#O'
  1536. X        directives in the preceding section.
  1537. X
  1538. XThe picture of the screen menu has constant strings in the position
  1539. Xthey will be output to the screen and '%' or '@' in each position
  1540. Xwhere the current value of some variable is to be displayed by
  1541. XGlib.  The locations of the '%'s and '@'s are remembered in the
  1542. Xorder in which they are encountered (scanning left-to-right and
  1543. Xtop-to-bottom in the picture), then the corresponding row/column
  1544. Xcoordinates are substituted for '%%'s and '@@'s encountered in
  1545. Xsection 3 of the source file.  The '%'s and '@'s are stored
  1546. Xindependently so as to make it more convenient to specify menus
  1547. Xthat have two columns of values.
  1548. X
  1549. XThe '#O' specifications are given in the form:
  1550. X
  1551. X#O <NAME> <TYPE> <POS> <MAX> <OFFSET> <MASK> <SHIFT> <ADHOC>
  1552. X
  1553. XSuch a line generates one "paraminfo" entry for an array, and some of
  1554. Xthe information is saved and made use of in generating 'setval' and
  1555. X'getval' calls.  NAME is the name of a variable label (no caps); TYPE is
  1556. Xthe name of a vis-function used to display the current value on the
  1557. Xscreen; POS should be either '%%' or '@@', which will be replaced by row
  1558. Xand column coordinates of the position to display the value; MAX is the
  1559. Xmaximum value the glib editor is to accept (the minimum is assumed to be
  1560. X0); OFFSET is the offset of the byte containing the value in the data
  1561. Xarray.  (If OFFSET is negative, the (positive) value is taken to be the
  1562. Xinitial value rather than the offset.)
  1563. X
  1564. XThe NAME argument may begin with a digit specifying a repetition
  1565. Xcount.  It's a shortcut which is like giving several consecutive
  1566. X#O-lines for <NAME>1, <NAME>2, ...
  1567. X
  1568. XThe last three #O arguments are optional.  MASK is a number with 1-bits
  1569. Xin positions holding the value for those cases where part of a byte is
  1570. Xused for some other purpose.  SHIFT is the number of bits the bitfield
  1571. Xis shifted left in the byte.  So, for instance, if the synth keeps a
  1572. Xvalue in the 4th, 5th, and 6th bits, one would give '0x1C' for the MASK
  1573. Xand '3' for SHIFT.  (Use caps for hex digits A-F.)
  1574. X
  1575. XThere is no systematic provision for values some of whose bits are found
  1576. Xin one byte, some in another.  The ADHOC argument has the form
  1577. X'*<digit>' and is used in the example to provide for such a case.  The
  1578. Xcode below in this file was just made up ad hoc for two such cases I
  1579. Xencountered with the Kawai K1.
  1580. X
  1581. X*/
  1582. X
  1583. X/*
  1584. X * Modified 4-13-89 by Scott Snyder:
  1585. X *  1. Increased MAXVAL from 100 to 200 (for DX7).
  1586. X *  2. Changed type of temps from 'unsigned char' to 'unsigned' (for DX7).
  1587. X *  3. Added command line processing (since TMAKE doesn't support redirection).
  1588. X *
  1589. X * 4-19-18
  1590. X *  Fixed bug with zero offsets.
  1591. X */
  1592. X
  1593. X#ifdef AZTEC_C
  1594. Xlong atol();
  1595. X# define strtol(a, b, c) atol(a)
  1596. X#endif
  1597. X#define MAXLINE 133
  1598. X#define MAXVAL 200
  1599. X#define MAXVSTRINGS 200
  1600. X#define MAXBUF 2000
  1601. X
  1602. X    char *infname = "file.mnu";
  1603. X    int lcnt = 1;
  1604. X    int i, j, k, wcol=0, col=0, row=0;
  1605. X    char word[MAXLINE];
  1606. X    int wordp = 0;
  1607. X    int valpos[MAXVAL][2];
  1608. X    int valpos2[MAXVAL][2];
  1609. X    int valcnt = 0;
  1610. X    int valcnt2= 0;
  1611. X    int offset;
  1612. X    int nlist[MAXVSTRINGS][6];
  1613. X    int np = 0;
  1614. X    char buf[MAXBUF];
  1615. X    int bufp=0;
  1616. X    int multiple, special;
  1617. X        int vmin, vmax, vval, mask, vshift, vrow, vcol, iflag;
  1618. X    char visfunc[20];
  1619. X    int state;
  1620. X%}
  1621. X
  1622. X%s M IG VAL O P Q
  1623. X
  1624. X%%
  1625. X
  1626. X<IG>^#[ \t]*MENU.*\n    { BEGIN(M); lcnt++; }
  1627. X<IG>\n            { ECHO; lcnt++; }
  1628. X<IG>.            ECHO;
  1629. X
  1630. X<M>"@"    {    writeword();
  1631. X        if (valcnt2+1 >= MAXVAL) {
  1632. X            fprintf(stderr,"menutoc: too many @s in menu\n");
  1633. X            exit(1);
  1634. X        }
  1635. X        valpos2[valcnt2][0] = row;
  1636. X        valpos2[valcnt2++][1] = col;
  1637. X        col += 1;
  1638. X};
  1639. X
  1640. X<M>"%"    {    writeword();
  1641. X        if (valcnt+1 >= MAXVAL) {
  1642. X            fprintf(stderr,"menutoc: too many %%s in menu\n");
  1643. X            exit(1);
  1644. X        }
  1645. X        valpos[valcnt][0] = row;
  1646. X        valpos[valcnt++][1] = col;
  1647. X        col += 1;
  1648. X};
  1649. X
  1650. X<M>[ ]*    {    if (yyleng > 4) writeword();
  1651. X        else if (wordp) for (i=0; i<yyleng; i++) append(' ');
  1652. X        col += yyleng;
  1653. X};
  1654. X
  1655. X<M>\t  {    writeword(); col = ((col + 8)/8)*8;
  1656. X};
  1657. X
  1658. X<M>\n  {    writeword(); col = 0; row += 1; lcnt++;
  1659. X};
  1660. X
  1661. X<M>.  {        append(yytext[0]); col += 1;
  1662. X};
  1663. X
  1664. X<M>^#[ \t]*END.*\n  {
  1665. X        BEGIN(VAL); i = 0; j = 0; lcnt++;
  1666. X        printf("# line %d \"%s\"\n", lcnt, infname);
  1667. X};
  1668. X
  1669. X<VAL>^"#O"[ \t]+  {
  1670. X        if (np+1 >= MAXVSTRINGS) {
  1671. X            fprintf(stderr,"menutoc: too many VSTRINGs\n");
  1672. X            exit(1);
  1673. X        }
  1674. X        BEGIN(O);
  1675. X        multiple = special = 0;
  1676. X        vmax = offset = mask = vshift = vmin = vrow = vcol = iflag = 0;
  1677. X        state = 0;
  1678. X};
  1679. X
  1680. X<O>[0-9]    multiple = atoi(yytext);
  1681. X
  1682. X<O>[a-z][a-z_0-9]*  {
  1683. X        if (bufp+yyleng >= MAXBUF) {
  1684. X            fprintf(stderr,"menutoc: out of storage room\n");
  1685. X            exit(1);
  1686. X        }
  1687. X        nlist[np][0] = bufp;
  1688. X        strcpy(buf+bufp, yytext);
  1689. X        bufp += yyleng+1;
  1690. X        BEGIN(P);
  1691. X};
  1692. X
  1693. X<P>[ \t]*    ;
  1694. X<P>[a-z0-9_]+  {
  1695. X        strcpy(visfunc, yytext);
  1696. X        if (yyleng >= 20) {
  1697. X            fprintf(stderr,"menutoc: vis name too long\n");
  1698. X            exit(1);
  1699. X        }
  1700. X        BEGIN(Q);
  1701. X};
  1702. X
  1703. X<Q>[ \t]*    ;
  1704. X<Q>\n  {    lcnt++;
  1705. X        if (special == 5) vmin = 1;
  1706. X        else vmin = 0;
  1707. X        if (offset < 0) vval = -offset;
  1708. X        else vval = 0;
  1709. X
  1710. X        if (multiple) for (k=0; k<multiple; k++) {
  1711. X            printf("\"%s%d\",NULL,-1,-1,%d,%d,vis%s,%d,%d,%d,0,\n",
  1712. X                buf+nlist[np][0], k+1, vrow, vcol, visfunc,
  1713. X                vmin, vmax, vval);
  1714. X            if (k+1 < multiple) {
  1715. X            if (iflag) {
  1716. X                if (i < valcnt) {
  1717. X                vrow = valpos[i][0]; vcol = valpos[i++][1];
  1718. X                } else
  1719. X                fprintf(stderr,"menutoc: too many %%%%s\n");
  1720. X            } else
  1721. X                if (j < valcnt2) {
  1722. X                vrow = valpos2[j][0]; vcol = valpos2[j++][1];
  1723. X                } else
  1724. X                fprintf(stderr,"menutoc: too many @@s\n");
  1725. X            }
  1726. X        }
  1727. X        else
  1728. X            printf("\"%s\",NULL,-1,-1,%d,%d,vis%s,%d,%d,%d,0,\n",
  1729. X                buf+nlist[np][0], vrow, vcol, visfunc,
  1730. X                vmin, vmax, vval);
  1731. X        if (multiple)
  1732. X            printf("# line %d \"%s\"\n", lcnt, infname);
  1733. X        nlist[np][1] = offset;
  1734. X        nlist[np][2] = mask;
  1735. X        nlist[np][3] = vshift;
  1736. X        nlist[np][4] = multiple;
  1737. X        nlist[np][5] = special;
  1738. X        np++;
  1739. X        BEGIN(VAL);
  1740. X};
  1741. X
  1742. X<Q>"-"*[0-9A-Fx]+  {
  1743. X        k = (int)strtol(yytext, (char **)NULL, 0);
  1744. X        switch (state) {
  1745. X          case 0: vmax = k;   break;
  1746. X          case 1: offset = k; break;
  1747. X          case 2: mask = k;   break;
  1748. X          case 3: vshift = k; break;
  1749. X          case 4: vmin = k;   break;
  1750. X                }
  1751. X                ++state;
  1752. X};
  1753. X
  1754. X<Q>"%%"  {    if (i < valcnt) {
  1755. X            vrow = valpos[i][0];
  1756. X            vcol = valpos[i][1];
  1757. X            i++;
  1758. X            iflag++;
  1759. X        }
  1760. X        else fprintf(stderr,"\nmenutoc: too many %%%%s\n");
  1761. X};
  1762. X<Q>"@@"  {    if (j < valcnt2) {
  1763. X            vrow = valpos2[j][0];
  1764. X            vcol = valpos2[j][1];
  1765. X            j++;
  1766. X        }
  1767. X        else fprintf(stderr,"\nmenutoc: too many @@s\n");
  1768. X};
  1769. X<Q>"--"  {    vrow = -1;
  1770. X        vcol = -1;
  1771. X};
  1772. X<Q>"*"[1-9]  {
  1773. X        special = yytext[1] - '0';
  1774. X};
  1775. X<VAL>.        ECHO;
  1776. X<VAL>\n        { ECHO; lcnt++; }
  1777. X
  1778. X<VAL>^#[ \t]*SETVAL.*\n  {
  1779. X        lcnt++;
  1780. X        /* make sure i,k will be used before declaring them */
  1781. X        for (k=0; k<np; k++)
  1782. X            if (nlist[k][1]>=0 && (nlist[k][5] || nlist[k][2])) {
  1783. X                printf("\tINT16 i, k;\n\n");
  1784. X                break;
  1785. X            }
  1786. X        for (k=0; k<np; k++) dosetval(k);
  1787. X        printf("# line %d \"%s\"\n", lcnt, infname);
  1788. X};
  1789. X
  1790. X<VAL>^#[ \t]*GETVAL.*\n  {
  1791. X        lcnt++;
  1792. X        /* make sure i,j,k will be used before declaring them */
  1793. X        for (k=0; k<np; k++)
  1794. X            if (nlist[k][1]>=0 && (nlist[k][5] || nlist[k][2])) {
  1795. X                printf("\tINT16 i, j, k;\n\n");
  1796. X                break;
  1797. X            }
  1798. X        for (k=0; k<np; k++) dogetval(k);
  1799. X        printf("# line %d \"%s\"\n", lcnt, infname);
  1800. X};
  1801. X
  1802. X<VAL>\\%%+    printf("%s", yytext+1);
  1803. X<VAL>\\@@+    printf("%s", yytext+1);
  1804. X
  1805. X<VAL>"@@"  {    if (j < valcnt2) {
  1806. X            printf("%d, %d", valpos2[j][0], valpos2[j][1]);
  1807. X            j++;
  1808. X        }
  1809. X        else fprintf(stderr,"\nmenutoc: too many @@s\n");
  1810. X};
  1811. X
  1812. X<VAL>"%%"  {    if (i < valcnt) {
  1813. X            printf("%d, %d", valpos[i][0], valpos[i][1]);
  1814. X            i++;
  1815. X        }
  1816. X        else fprintf(stderr,"\nmenutoc: too many %%%%s\n");
  1817. X};
  1818. X
  1819. X<VAL>.        ECHO;
  1820. X<VAL>\n        { ECHO; lcnt++; }
  1821. X
  1822. X%%
  1823. Xdosetval(k)
  1824. Xint k;
  1825. X{    int m;
  1826. X
  1827. X    special  = nlist[k][5];
  1828. X
  1829. X    if (special == 1 || special == 3) k++;
  1830. X    else if (special == 2 || special == 4) k--;
  1831. X
  1832. X    bufp     = nlist[k][0];
  1833. X    offset   = nlist[k][1];
  1834. X    mask     = nlist[k][2];
  1835. X    vshift   = nlist[k][3];
  1836. X    multiple = nlist[k][4];
  1837. X
  1838. X    if (offset < 0) return;
  1839. X
  1840. X    if (multiple) for (m = 1; m <= multiple; m++)
  1841. X    {    outsetval(m); offset++;        }
  1842. X    else    outsetval(0);
  1843. X}
  1844. X
  1845. Xoutsetval(m)
  1846. Xint m;
  1847. X{
  1848. X    if (!mask && !special) {
  1849. X        printf("setval(\"%s", buf+bufp);
  1850. X        if (m) printf("%d", m);
  1851. X        printf("\",(INT16)data[RESERVESIZE+%d]);\n",offset);
  1852. X        return;
  1853. X    }
  1854. X
  1855. X    printf("i = (INT16)data[RESERVESIZE+%d]; ", offset);
  1856. X    if (mask) {
  1857. X        printf("i &= %d; ", mask);
  1858. X        if (vshift) printf("i >>= %d; ", vshift);
  1859. X    }
  1860. X
  1861. X    if (special == 2) printf("i += k << 1;\n");
  1862. X    else if (special == 4) printf("i += k << 7;\n");
  1863. X
  1864. X    if (special == 1 || special == 3) printf("k = i;\n");
  1865. X    else {
  1866. X        printf("setval(\"%s", buf+bufp);
  1867. X        if (m) printf("%d", m);
  1868. X        printf("\",i);\n");
  1869. X    }
  1870. X}
  1871. X
  1872. Xdogetval(k)
  1873. Xint k;
  1874. X{    int m;
  1875. X
  1876. X    bufp     = nlist[k][0];
  1877. X    offset   = nlist[k][1];
  1878. X    mask     = nlist[k][2];
  1879. X    vshift   = nlist[k][3];
  1880. X    multiple = nlist[k][4];
  1881. X    special  = nlist[k][5];
  1882. X
  1883. X    if (offset < 0) return;
  1884. X
  1885. X    if (multiple) for (m = 1; m <= multiple; m++)
  1886. X    {    outgetval(m); offset++;        }
  1887. X    else    outgetval(0);
  1888. X}
  1889. X
  1890. Xoutgetval(m)
  1891. Xint m;
  1892. X{
  1893. X    if (!mask && !special) {
  1894. X        printf("data[RESERVESIZE+%d] = ", offset);
  1895. X        printf("getval(\"%s", buf+bufp);
  1896. X        if (m) printf("%d", m);
  1897. X        printf("\");\n");
  1898. X        return;
  1899. X    }
  1900. X
  1901. X    if (special == 2 || special == 4)
  1902. X        printf("i = k; ");
  1903. X    else {
  1904. X        printf("i = getval(\"%s", buf+bufp);
  1905. X        if (m) printf("%d", m);
  1906. X        printf("\"); ");
  1907. X    }
  1908. X
  1909. X    if (special == 1) printf("k = i >> 1; i &= 1;\n");
  1910. X    else if (special == 3) printf("k = i >> 7; i &= 0x7f;\n");
  1911. X
  1912. X    if (mask) {
  1913. X        printf("j = data[RESERVESIZE+%d]; ", offset);
  1914. X        if (vshift) printf("i <<= %d; ", vshift);
  1915. X        printf("j &= ~%d; ", mask);
  1916. X        printf("i = j|i; ");
  1917. X    }
  1918. X    printf("data[RESERVESIZE+%d] = i;\n", offset);
  1919. X}
  1920. X
  1921. Xmain(argc, argv)
  1922. Xint argc;
  1923. Xchar **argv;
  1924. X{    char *basename();
  1925. X
  1926. X  if (argc > 1) {
  1927. X    infname = basename(argv[1]);
  1928. X    if (freopen(argv[1], "r", stdin) == NULL) {
  1929. X      perror("Can't open input file");
  1930. X      exit(1);
  1931. X    }
  1932. X  }
  1933. X  if (argc > 2) {
  1934. X    if (freopen(argv[2], "w", stdout) == NULL) {
  1935. X      perror("Can't open output file");
  1936. X      exit(1);
  1937. X    }
  1938. X  }
  1939. X
  1940. X    word[0] = 0;
  1941. X    BEGIN(IG);
  1942. X    yylex();
  1943. X    if (i < valcnt) fprintf(stderr,"\nmenutoc: not enough %%%%s\n");
  1944. X    if (j < valcnt2) fprintf(stderr,"\nmenutoc: not enough @@s\n");
  1945. X    exit(0);
  1946. X}
  1947. X
  1948. Xchar   *basename(s)
  1949. Xchar   *s;
  1950. X{
  1951. X    char   *p;
  1952. X    char   *strrchr();
  1953. X
  1954. X    if (p = strrchr (s, '/'))
  1955. X        return (++p);
  1956. X    else
  1957. X        return (s);
  1958. X}
  1959. X
  1960. Xappend(c)
  1961. Xchar c;
  1962. X{
  1963. X    if (wordp+1 >= MAXLINE) {
  1964. X        fprintf(stderr,"menutoc: string in menu too long\n");
  1965. X        exit(1);
  1966. X    }
  1967. X    if (!wordp) wcol = col;
  1968. X    word[wordp++] = c;
  1969. X    word[wordp] = 0;
  1970. X}
  1971. X
  1972. Xwriteword()
  1973. X{
  1974. X    if (wordp) {
  1975. X        while (word[--wordp] == ' ') ;
  1976. X        word[++wordp] = 0;
  1977. X        printf("%d,%d,\"%s\",\n", row, wcol, word);
  1978. X        wordp = 0;
  1979. X        word[wordp] = 0;
  1980. X    }
  1981. X}
  1982. END_OF_FILE
  1983. if test 12722 -ne `wc -c <'menutoc.l'`; then
  1984.     echo shar: \"'menutoc.l'\" unpacked with wrong size!
  1985. fi
  1986. # end of 'menutoc.l'
  1987. fi
  1988. echo shar: End of archive 7 \(of 15\).
  1989. cp /dev/null ark7isdone
  1990. MISSING=""
  1991. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  1992.     if test ! -f ark${I}isdone ; then
  1993.     MISSING="${MISSING} ${I}"
  1994.     fi
  1995. done
  1996. if test "${MISSING}" = "" ; then
  1997.     echo You have unpacked all 15 archives.
  1998.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1999. else
  2000.     echo You still need to unpack the following archives:
  2001.     echo "        " ${MISSING}
  2002. fi
  2003. ##  End of shell archive.
  2004. exit 0
  2005.  
  2006.